﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Registration.aspx.cs" Inherits="Registration" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>

    <script type="text/javascript">
        function passValidator(source, args) {
            //var passElement = document.getElementById('<%= txtPass1.ClientID %>');
            var flag = false;
            for (var i = 0; i < args.Value.length; i++) {
                var ch = args.Value.charAt(i);

                if (ch >= 48 && ch <= 62) {
                    flag = true;
                    break;
                }
            }
            if (flag == false)
                args.IsValid = false;
            else
                args.IsValid = true;
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <table style="width: 300px">
        <tr>
            <td style="width: 140px">
                <asp:Label ID="Label1" runat="server" Text="Name" />
            </td>
            <td>
                <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="valName" runat="server" ErrorMessage="Name should not be blank"
                    ControlToValidate="txtName" />
            </td>
        </tr>
        <tr>
            <td style="width: 140px">
                <asp:Label ID="Label2" runat="server" Text="Age" />
            </td>
            <td>
                <asp:TextBox ID="txtAge" runat="server"></asp:TextBox>
                <asp:RangeValidator ID="RangeValidator1" runat="server" ErrorMessage="Age should be in between 18 and 30"
                    MaximumValue="30" MinimumValue="18" ControlToValidate="txtAge" />
            </td>
        </tr>
        <tr>
            <td style="width: 140px">
                <asp:Label ID="Label3" runat="server" Text="Password" />
            </td>
            <td>
                <asp:TextBox ID="txtPass1" runat="server" TextMode="Password"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Plz. enter password"
                    ControlToValidate="txtPass1" />
                &nbsp;<asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Password should contain one numeric vale"
                    ClientValidationFunction="passValidator" ControlToValidate="txtPass1" />
            </td>
        </tr>
        <tr>
            <td style="width: 140px">
                <%-- <table style="background-color:Red; width:100%">
                    <tr>
                        <td>
                            Hi
                        </td>
                    </tr>
                </table>--%>
                <asp:Label ID="Label4" runat="server" Text="Re Type Password" />
            </td>
            <td>
                <asp:TextBox ID="txtPass2" runat="server" TextMode="Password"></asp:TextBox>
                <asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="Password is not same"
                    ControlToValidate="txtPass2" ControlToCompare="txtPass1" />
            </td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <asp:Button ID="btnRegister" runat="server" Text="Reg. me" OnClick="btnRegister_Click" />
            </td>
        </tr>
    </table>
    </form>
</body>
</html>
